<?php

declare(strict_types=1);

namespace app\core\Anotation;
use app\core\Container\Reflection\ReflectionContainer;

class Base{

    public function __construct()
    {   
        $classObject= ReflectionContainer::getClassReflection(static::class);
        $params =$classObject->getConstructor()->getParameters();
        $data=[];
        if(!empty($params)){
            $args=\func_get_args();
            $filledData=[];
            foreach($params as $k=>$param){
                if ($param->isOptional()) {
                    $data[$param->getName()]=$param->getDefaultValue();
                    if(array_key_exists($k,$args)){
                        $filledData[$param->getName()]=$args[$k];
                    }
                }
            }
            if(array_key_exists('callable',$data)){
                call_user_func($data['callable'],...$filledData);
            }
        }
    }
}